﻿using System;
using System.Collections.Generic;
using ThirdServices.AlertModel.Providers.Wanderground.Factory;
using ThirdServices.AlertModel.Factory.BaseInterface;
using ThirdServices.AlertModel.Factory.Entities.DTO;
using GNSCore.Model.Context;
using GNSCore.Repositories;
using GNSCore.Repositories.IOC;
using GNSCore.Managers;
using GNSCore.Model;
using GNSCore.Managers.Statistics;  


namespace TestServices
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            double lat = 49.9966392, lon = 36.2572576;
            var wander_temp = new WandergroundAlerts();
            IAlert wAlertTemp = wander_temp.CreateTemperatureAlert(lat, lon, 30, 3);
            List<BaseAlert> baseAlerts = wAlertTemp.CheckAlert();
            foreach (BaseAlert ba in baseAlerts)
            {
                Console.WriteLine(ba.NotificationDescription.alert_type + "\n" + ba.NotificationDescription.notification);
            }
            if (baseAlerts.Count == 0)
                Console.WriteLine("No alerts");

            IOCManager.ConfigureContainer(new GNSDBEntities());
            IRepository<GNSCore.Model.GeoData> geoData = IOCManager.IOCContainer.Resolve<IRepository<GeoData>>();
            IRepository<GNSCore.Model.GeoExtensionData> geoExtensionData = IOCManager.IOCContainer.Resolve<IRepository<GeoExtensionData>>();

            IGNSContext context = IOCManager.IOCContainer.Resolve<IGNSContext>();
            geoData.SetContext(context);
            geoExtensionData.SetContext(context);

            
            StatisticManager statisticManager = new StatisticManager(
                geoData, geoExtensionData);
            statisticManager.SaveStatistic(baseAlerts);


            //statisticManager.SaveStatistic(listBaseAlert);


            Console.ReadLine();
        }
    }
}